//
//  YBStoryCollectionViewCell.m
//  OurTourism
//
//  Created by 孟镇 on 15/12/7.
//  Copyright © 2015年 Devil_Coming. All rights reserved.
//

#import "YBStoryCollectionViewCell.h"
#import "Header.h"
#import "YBPhotoCollectionViewCell.h"

@interface YBStoryCollectionViewCell ()<UICollectionViewDataSource , UICollectionViewDelegate>

@property (nonatomic, strong)UICollectionView *Collection;
@end

@implementation YBStoryCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    
    self = [super initWithFrame:frame];
    if (self) {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        layout.itemSize = CGSizeMake((WIDTH -10)/ 2, 200);
        layout.minimumInteritemSpacing = 5;
        layout.minimumLineSpacing = 5;
        layout.scrollDirection = UICollectionViewScrollDirectionVertical;
        layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
        
        
        self.Collection = [[UICollectionView alloc] initWithFrame:self.contentView.frame collectionViewLayout:layout];
        
        
        self.Collection.collectionViewLayout = layout;
        self.Collection.backgroundColor = [UIColor colorWithRed:250 / 255. green:246 / 255. blue:232 / 255. alpha:1];
        self.Collection.delegate = self;
        self.Collection.dataSource = self;
        self.Collection.showsHorizontalScrollIndicator = NO;
        self.Collection.showsVerticalScrollIndicator = NO;
        
        [self.Collection registerClass:[YBPhotoCollectionViewCell class] forCellWithReuseIdentifier:@"collection"];
        [self.contentView addSubview:self.Collection];

    }
    return self;
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    YBPhotoCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"collection" forIndexPath:indexPath];
  
    
    cell.model = self.arr[indexPath.item];
    return  cell;
    
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.arr.count;
}

@end
